var directives = angular.module("directives", ['services', 'gobals']);

directives.directive('smartyNav', function (settingService, gobalService) {

    return {
        restrict: 'A',
        link: function (scope, element, attr, ctrl) {

            var cfg = gobalService.config();

            //加载配置信息
            var pro = settingService.getServices(cfg.sysKey);

            pro.then(function (result) {

                scope.services = result;

                var showSize = 0;

                if (scope.services.daijia) {
                    showSize++;
                }
                if (scope.services.zhuanche) {
                    showSize++;
                }
                if (scope.services.paotui) {
                    showSize++;
                }
                if (scope.services.xiche) {
                    showSize++;
                }

                scope.showSize = showSize;

                if (showSize <= 1) {
                    element.css('display', 'none');
                } else {
                    element.css('display', 'block');
                }

            });
        }
    }
});